//
//  NHomeHeaderView.m
//  nncloud
//
//  Created by macfai on 2018/9/18.
//  Copyright © 2018年 youedata. All rights reserved.
//

#import "NHomeHeaderView.h"
#import "NFourIconView.h"
#import "UIView+Sizes.h"
#import "SDCycleScrollView.h"

@interface NHomeHeaderView()<SDCycleScrollViewDelegate>

@property(nonatomic,strong)SDCycleScrollView *cycleView;
@property (nonatomic,strong)NFourIconView *iconView;

@end

@implementation NHomeHeaderView


-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self setUI];
//        self.backgroundColor = [UIColor magentaColor];
        
    }
    return self;
}

- (void)setUI{
    
    //1添加轮播图
    _cycleView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenWidth>320?cycleHight:150) delegate:self placeholderImage:[UIImage imageNamed:@"firstPageBanner1.png"]];
    _cycleView.currentPageDotColor = NColorRGB(253.f, 80.f, 115.f);
    _cycleView.pageDotColor = kLightGrayColor;
    _cycleView.autoScrollTimeInterval = 5;
    _cycleView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
    _cycleView.localizationImageNamesGroup = @[@"firstPageBanner1.png",@"firstPageBanner2.png",@"firstPageBanner3.png",@"firstPageBanner4.png"];
    [self addSubview:_cycleView];
    
    
//    UIImageView *imgview = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, cycleHight)];
//    imgview.image = WDImgName(@"firstPageBanner1.png");
//    [self addSubview:imgview];
    
    //高度减1是为了留出一条线
    WeakStament(wself);
    NFourIconView *view = [[NFourIconView alloc]initWithFrame:CGRectMake(0,cycleHight, ScreenWidth, fourIconHight-1)];
    
//    view.backgroundColor = [UIColor blueColor];
    view.iconArray = @[@"icon1",@"icon2",@"icon3",@"icon4"];
    view.titleArray = @[@"营商环境",@"工业运行监测",@"金融服务",@"大数据应用"];
    
    view.indexBlock = ^(NSInteger indexNum, NFourIconModel *model) {
      
        if (wself.indexBlock) {
            wself.indexBlock(indexNum, model);
        }
    };
    
    [self addSubview:view];




}

//轮播图数据设置
-(void)setBannerArray:(NSArray *)bannerArray{
    
//    _bannerArray = bannerArray;
//
//    NSMutableArray* arr = [NSMutableArray array];
//
//    for (WDBannerModel* model in bannerArray) {
//
//        NSString *url = model.imageUrl;
//
//        [arr addObject:url];
//    }
//    _cycleView.imageURLStringsGroup = arr;
}


#pragma mrak - SDCycleScrollViewDelegate
-(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    
    YYLog(@"%ld",index);
//    if (_bannerBlock) {
//        _bannerBlock(index);
//    }
}








@end
